__author__ = 'MyHome'
#from django.utils import simplejson
import json
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register

from documentation.models import Category, Documents
from django.template import RequestContext
from django.template.loader import render_to_string


@dajaxice_register
def fill_table(request, mt):
    dajax = Dajax()
    Docs=Documents.objects.filter(section__title=mt)
    html=render_to_string("docstable.html",{'Docs':Docs})
    dajax.assign('#ajax-table','innerHTML',html)
    return dajax.json()


@dajaxice_register
def all_data(request):
    dajax = Dajax()
    Docs=Documents.objects.order_by("title")
    html=render_to_string("docstable.html",{'Docs':Docs})
    dajax.assign('#ajax-table','innerHTML',html)
    return dajax.json()
